<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="/js/jquery-3.2.1.min.js"></script>
    <script src="/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>
</head>
<body>
<!--图片上传-->
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="employId" class="layui-form-label">
                <span class="x-red">*</span>编号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="employId" name="employId" required="" lay-verify="employId"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="e_name" class="layui-form-label">
                <span class="x-red">*</span>姓名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="e_name" name="e_name" required="" lay-verify="e_name"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="beforePost" class="layui-form-label">
                <span class="x-red">*</span>原部门
            </label>
            <div class="layui-input-inline">
                <input type="text" id="beforePost" name="beforePost" required="" lay-verify="beforePost"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="newPost" class="layui-form-label">
                <span class="x-red">*</span>新职务
            </label>
            <div class="layui-input-inline">
                <input type="text" id="newPost" name="newPost" required="" lay-verify="newPost"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="time" class="layui-form-label">
                <span class="x-red">*</span>调用时间
            </label>
            <div class="layui-input-inline">
                <input type="text" id="time" name="time" required="" lay-verify="time"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="remarks" class="layui-form-label">
                <span class="x-red">*</span>调用原因
            </label>
            <div class="layui-input-inline">
                <input type="text" id="remarks" name="remarks" required="" lay-verify="remarks"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="remarks" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" lay-submit="">
                保存
            </button>
        </div>
    </form>
</div>
</body>
</html>

<script>
    layui.use('laydate', function() {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#time'
        });
    });

    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;
//新增按钮
        form.on('submit(add)', function(data){

            console.log(data.field);

            $.ajax({
                url:"/deploy/save/add",
                async: false,
                contentType: 'application/json;charset=UTF-8',
                type:"POST",
                dataType: "json",
                data:JSON.stringify(data.field),
                success: function(data){
                    if(data==true){
                        layer.alert("增加成功", {icon: 6},function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            //刷新
                            parent.window.location.replace("/deploy/list")
                        });
                    }else{
                        layer.msg('增加失败!',{icon: 6,time:1000});
                    }

                },
                error:function () {
                    layer.msg('ajax请求失败!',{icon: 6,time:1000});
                }
            });
            return false;
        });
    });
</script>